/*
 *  @Description:
 *  * @since:         2023/5/4 上午9:53
 *  * @author:       瓦尔
 *
 */
package com.wal.aiclient.controller;

import com.wal.aiclient.common.PythonServiceClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {

    /****  诗词ai
     * http://127.0.0.1:8080/ai?text=乒乓
     * */
    @RequestMapping("/ai")
    public Object ai(String text) {
        System.out.println("begin..........请求参数:" + text);

//        String pythonUrl = "http://localhost:8888/ai"; // Python服务的URL
        String pythonUrl = "http://11.11.115.136:8888/ai"; // Python服务的URL
        PythonServiceClient client = new PythonServiceClient(pythonUrl);
        String result = null;
        try {
            result = client.translate(text);
            System.out.println("计算结果：" + result);
        } catch (Exception e) {
            result = e.getMessage();
            System.out.println("计算出错：" + e.getMessage());
        }
        return result;
    }

}
